﻿using System;
using System.IO;
using System.Windows.Forms;
using ColorCode;

namespace RegExpRegExpGenerator
{
    public partial class GeneratedCode : Form
    {
        public GeneratedCode(string code)
        {
            InitializeComponent();
            this.code = code;
        }

        /// <summary>
        ///     The exported code
        /// </summary>
        public string code { get; set; }

        /// <summary>
        ///     On save-as
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveAs_Click(object sender, EventArgs e)
        {
            saveFileDialog.ShowDialog(); // Show the dialog
            string name = saveFileDialog.FileName; // Get file name
            File.WriteAllText(name, code); // Writes file
            Close(); // Closes document
        }

        private void GeneratedCode_Load(object sender, EventArgs e)
        {
            // Sets syntax highlighting
            txtCode.DocumentText = new CodeColorizer().Colorize(code, Languages.CSharp);
        }
    }
}